package app.component;

import java.awt.BorderLayout;

import javax.swing.JFrame;

import chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer;

/**
 * @author Evstigneev Kirill (kester)
 */
public class ImageAnimator extends JFrame {

	private final static String TITLE = "Image Animator";
	private JFlashPlayer flashPlayer;
	private StatusBar statusBar;
	private ImageAnimatorToolbar toolbar;

	public void init() {
		setLayout(new BorderLayout());
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(800, 600);
		setLocationByPlatform(true);
		setTitle(TITLE);

		flashPlayer = createFlashPlayer();
		statusBar = createStatusbar();
		toolbar = createToolbar();

//		loadTestFile();

	    add(toolbar, BorderLayout.PAGE_START);
	    add(flashPlayer, BorderLayout.CENTER);
	    add(statusBar, BorderLayout.PAGE_END);
	}

	private ImageAnimatorToolbar createToolbar() {
		final ImageAnimatorToolbar toolbar = new ImageAnimatorToolbar(this, flashPlayer, statusBar);
		toolbar.init();
		return toolbar;
	}

	private JFlashPlayer createFlashPlayer() {
		final JFlashPlayer flashPlayer = new JFlashPlayer();
	    return flashPlayer;
	}

	private StatusBar createStatusbar() {
		final StatusBar statusBar = new StatusBar();
		statusBar.init();
		return statusBar;
	}

	public void loadTestFile() {
		//TODO remove
		String swfName = "Movement-pointer_or_click.swf";
	    flashPlayer.load(swfName);
	    toolbar.updateProjectName(swfName);
	    // --
	}

}
